﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LoungeRepo.Contracts.EntityStore;
using LoungeRepo.Contracts.Normalizer;
using LoungeRepo.Extensions;

namespace LoungeRepo.Core
{
    partial class LoungeRepository
    {
        private void PersistNormalizedEntities(IEnumerable<INormalizedEntity> normalizedEntities)
        {
            normalizedEntities
                .Transform<INormalizedEntity, IStreamedEntity>(this.serializer.Serialize)
                .Transform(this.filesys.Store);
        }

        private INormalizedEntity DepersistNormalizedEntity(string id, string partition)
        {
            var streamedEntity = this.filesys.Load(id, partition);
            return this.serializer.Deserialize(streamedEntity);
        }
    }
}
